package com.ztesoft.book.admin.controller.sys;

import com.ztesoft.book.admin.controller.base.BaseController;
import com.ztesoft.book.common.utils.Result;
import com.ztesoft.book.core.sys.sysdict.dto.SysDictDTO;
import com.ztesoft.book.core.sys.sysdict.qo.SysDictQO;
import com.ztesoft.book.core.sys.sysdict.service.SysDictService;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 字典表
 *
 * @author 汤露露
 * 创建时间：2021-07-23
 */
@Slf4j
@RestController
@RequestMapping("/sys/sysDict")
@RequiresPermissions("sysDict:")
public class SysDictController extends BaseController<SysDictService, SysDictDTO, SysDictQO> {
    @Resource
    private SysDictService sysDictService;


    @Override
    protected SysDictService getService() {
        return sysDictService;
    }

    @GetMapping("/getSysDictListByTypeCode")
    public @ResponseBody
    Result getSysDictListByTypeCode(@RequestBody String typeCode) {
        try {
            List<SysDictDTO> list = sysDictService.getSysDictListByTypeCode(typeCode);

            return Result.success(list);
        }
        catch (Exception ex) {
            log.error(ex.getMessage());
            return Result.error("获取失败！");
        }
    }
}



